<template>
	<view style="background-color: #F0F0F0;">
		<view >
			<uni-card :is-full="true" >
				<view style="line-height: 60upx;">
					<view>
						<text class="title">【题目】</text>
						<rich-text :nodes="shiti.questionsname" style="text-indent: 0rem;"></rich-text>
					</view>
					<view>
						<text class="title">【我的答案】</text>
						<rich-text :nodes="shiti.myanswer"></rich-text>
					</view>
					<view>
						<text class="title">【答题时间】</text>
						<view>{{shiti.answertime}}</view>
					</view>
					<view>
						<text class="title">【评语】</text>
						<rich-text :nodes="shiti.comment"></rich-text>
					</view>
					<view>
						<text class="title">【得分】</text>
						<view class="score">{{shiti.score}}</view>
					</view>
					<view>
					
						<span class="title">【批改人】</span>
						<view class="comrname">{{ shiti.comrname }}</view>
					</view>
				</view>
				<button type="default" @click="shoucang">{{collectionFlag ? "取消收藏" : "收藏" }}</button>

			</uni-card>
		</view>
	</view>
</template>

<script>
	import uniCard from '@/components/uni-card/uni-card.vue'

	import userApi from "@/api/user.js"

	let _this;
	export default {
		components: {
			uniCard
		},

		data() {
			return {
				query:{},
				shiti:{},
				collectionFlag:true
			}
		},
		onLoad(query) {
			_this = this;
			_this.query = query
			_this.initData();
			
		},
		computed: {
			
		},
		methods: {
			initData() {
				userApi.dt_info(_this.query).then(res => {
					console.log(res)
					_this.shiti = res.data
				})
			},
			shoucang(){
				if(_this.collectionFlag){
					//取消收藏
					userApi.my_sc_qx(_this.query).then(res=>{
						_this.collectionFlag = false
					})
				}else{
					//收藏
					userApi.sc_st(_this.query).then(res=>{
						_this.collectionFlag = true
					})
				}
			}

		}
	}
</script>

<style lang="scss">
	page {
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
		background-color: #fff
	}

	view {
		font-size: 28upx;
		line-height: inherit
	}
	.title {
		color: #4f81bd;
	}
	.example {
		padding: 0 30upx 30upx
	}

	.example-title {
		font-size: 32upx;
		line-height: 32upx;
		color: #777;
		margin: 40upx 25upx;
		position: relative
	}

	.example .example-title {
		margin: 40upx 0
	}

	.example-body {
		padding: 0 40upx
	}
	.score {
		font-size: $font-sm + 2upx;
		color: $uni-color-primary;
		word-wrap: normal;
		overflow: hidden;
		line-height: 60upx;
		text-indent:1em;
	}
	
	.comrname {
		word-wrap: normal;
		overflow: hidden;
		line-height: 60upx;
		text-indent:1em;
	}
	
	rich-text{
		line-height: 60upx;
		text-indent:2em;
	}
</style>
